package com.keifo.final2.service;


import com.keifo.final2.entity.TeamMember;
import com.keifo.final2.mapper.TeamMemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeamMemberService {

    @Autowired
    private TeamMemberMapper teamMemberMapper;

    public boolean validateLogin(String username, String password) {
        TeamMember member = teamMemberMapper.findByUsername(username);
        return member != null && member.getPassword().equals(password);
    }

    public List<TeamMember> getAllMembers() {
        return teamMemberMapper.findAll();
    }

    public TeamMember getMemberByUsername(String username) {
        return teamMemberMapper.findByUsername(username);
    }

    public void addMember(TeamMember member) {
        teamMemberMapper.insert(member);
    }

    public void updateMember(TeamMember member) {
        teamMemberMapper.update(member);
    }

    public void deleteMember(String username) {
        teamMemberMapper.delete(username);
    }
}